import Vue from 'vue'
import VueRouter from 'vue-router'
// import Login from "@/views/login/index.vue"
Vue.use(VueRouter)
// 页面导入方式1-单独导入
const routes = [
  {
    // 13.4 配置路径
    path: '/',
    redirect: '/home',
    component: () => import('@/views/layout'),
    children: [
    // 默认路径，当访问父路径/,访问子路径
      {
        path: 'home', component: () => import('@/views/Home')
      },
      {
        path: 'qa', component: () => import('@/views/qa')
      },
      {
        path: 'video', component: () => import('@/views/video')
      },
      {
        path: 'my', component: () => import('@/views/my')
      }
    ]

  },
  // { path: '/login', component: Login }
  // 方式二 - 通过箭头函数来进行导入
  {
    path: '/login', component: () => import('../views/login/index.vue')
  },
  {
    path: '/search', component: () => import('../views/search/index.vue')
  },
  // 方式一 ：通过query传参
  // path: '/article', component: () => import('../views/article/index.vue')
  // 方式二：通过params传参
  {
    // 路由配置
    name: 'article',
    path: '/article/:articleId',
    component:
  () => import('../views/article/index.vue'),
    props: true
  },
  {
    path: '/user/profile', component: () => import('../views/user-profile')
  }

]

const router = new VueRouter({
  routes
})

export default router
